<?php


//声明一个Human类，包含了姓名、性别、生日属性，定义一个方法计算出年龄。
class Human{
    public $name;
    public $sex;
    public $birthday;
    public function __construct($name,$sex,$birthday)
    {
        $this->name=$name;
        $this->sex=$sex;
        $this->birthday=$birthday;
    }
    public function age($name,$birthday){
        date_default_timezone_set("PRC");

        $strtotime = strtotime($birthday); //获取具体时间的时间戳

        $date =date("Y",$strtotime);//生日年份
        $datemonth = date("m",$strtotime);//生日月份

        $time = time(); //当前的时间戳
        $da = date("Y",$time); //当前的年份
        $damonth = date ("m",$time);

        $sum = $da - $date;
        $month = abs($damonth - $datemonth);
        echo $name ."的年龄为：".$sum."岁".$month."月";
    }
}
$Human = new Human('小白','男','2000-08-01');
 $Human->age($Human->name,$Human->birthday);

 echo "<br />";
//声明一个汽车Car类，包含了品牌、车型、价格等等属性，属性可以自由定义，可以参考汽车之家等相关平台。

class Car {
    public $Carname;//车的名称
    public $Cartype;//车型
    public $Carprie;//价格
    public $motor;//发动机
    public function __construct($Carname,$Cartype,$Carprie,$motor)
    {
        $this->Carname = $Carname;
        $this->Cartype = $Cartype;
        $this->Carprie = $Carprie;
        $this->motor = $motor;
    }
}

$Car = new Car('东风本田思域','大型车','15.6w','1.5T 177马力 L4');
var_dump($Car);